Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use rubato & symphonia for decoding & resampling #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Inrixia
Copy link

@Inrixia Inrixia commented Apr 20, 2024

Remove dependencies for:

  • tempfile
  • rodio
  • tempdir

Do all decode and resampling operations in memory using rubato & symphonia
This removes the dependency on ffmpeg and no longer writes to disk

Code is ported from my web assembly fork of this https://github.com/Inrixia/shazamio-core/tree/wasm I figured I might aswell do a pr to integrate some of the improvements I did into the main python version.
Its working perfectly fine there but I haven't tested it in the python version as I don't have the dev environment setup for it.

Remove dependencies for:
 - tempfile
 - rodio
 - tempdir

Do all decode and resampling operations in memory
@Inrixia
Copy link
Author

Inrixia commented Apr 21, 2024

My WebAssembly branch has a bunch of fixes & improvements that may be worth reviewing before considering merging this

@dotX12
Copy link
Collaborator

dotX12 commented Apr 22, 2024

Hello, I couldn’t get it to work the first time, I see problems. Could you help with this?

mp3 file

2024-04-22 11:14:15 - asyncio - [proactor_events.py:633 - __init__()] - DEBUG - Using proactor: IocpProactor
thread 'tokio-runtime-worker' panicked at src\fingerprinting\decode.rs:61:48:
attempt to multiply with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'tokio-runtime-worker' panicked at src\utils.rs:21:14:
called `Result::unwrap()` on an `Err` value: JoinError::Panic(Id(35), ...)
Traceback (most recent call last):
  File "C:\Users\ecelo\PycharmProjects\ShazamIO\examples\recognize_song.py", line 46, in <module>
    loop.run_until_complete(main())
  File "C:\Users\ecelo\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\ecelo\PycharmProjects\ShazamIO\examples\recognize_song.py", line 34, in main
    new_version_path = await shazam.recognize("data/Joey_Bada_THE_REV3NGE.mp3")
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ecelo\PycharmProjects\ShazamIO\shazamio\api.py", line 559, in recognize
    signature = await self.core_recognizer.recognize_path(data)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pyo3_asyncio.RustPanic: rust future panicked: unknown error

Process finished with exit code 1

ogg file

2024-04-22 11:15:45 - asyncio - [proactor_events.py:633 - __init__()] - DEBUG - Using proactor: IocpProactor
Traceback (most recent call last):
  File "C:\Users\ecelo\PycharmProjects\ShazamIO\examples\recognize_song.py", line 46, in <module>
    loop.run_until_complete(main())
  File "C:\Users\ecelo\AppData\Local\Programs\Python\Python311\Lib\asyncio\base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "C:\Users\ecelo\PycharmProjects\ShazamIO\examples\recognize_song.py", line 34, in main
    new_version_path = await shazam.recognize("data/dora.ogg")
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ecelo\PycharmProjects\ShazamIO\shazamio\api.py", line 559, in recognize
    signature = await self.core_recognizer.recognize_path(data)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SignatureError: unsupported feature: core (codec):unsupported codec

@Inrixia
Copy link
Author

Inrixia commented Apr 22, 2024

Hey, sorry yea I didn't have a python env so just did a dirty port of my branch (which has progressed a lot since then)
If you have a look at the state of the codebase on my wasm fork you can see the changes I have made. https://github.com/Inrixia/shazamio-core

Currently alongside completely removing the ffmpeg dependency it also only calculates data as needed and has additional options allowing for grabbing a specific area of a file.

I don't have the time to setup a python environment for porting my changes but it should be very easy for you to grab a fork of my branch and just add some new python types around the code to test it, are you able to do that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants